package org.xxpay.pay.channel.mfhpay;

import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;

/**
 * 魔法盒支付
 * @author: pangxiaoyu
 * @date: 2020年2月28日09:07:38
 */
@Component
public class MfhpayConfig {

    public static final String CHANNEL_NAME = "mfhpay";

    public static final String CHANNEL_NAME_ALI_H5 = CHANNEL_NAME + "_alipay_h5";
    public static final String CHANNEL_NAME_ALI_QR = CHANNEL_NAME + "_alipay_qr";

    public static final String RETURN_VALUE_SUCCESS = "success";
    public static final String RETURN_VALUE_ERROR = "error";

    // 商户账号
    private String mchId;
    // key
    private String key;
    // 请求地址
    private String reqUrl;
    // 支付类型
    private String payType = "9";

    public MfhpayConfig(){}

    public MfhpayConfig(String payParam) {
        Assert.notNull(payParam, "init "+ CHANNEL_NAME +" config error");
        JSONObject object = JSONObject.parseObject(payParam);
        this.mchId = object.getString("mchId");
        this.key = object.getString("key");
        this.reqUrl = object.getString("reqUrl");
        if(StringUtils.isNoneBlank(object.getString("payType"))) {
            this.payType = object.getString("payType");
        }
    }

    public String getMchId() {
        return mchId;
    }

    public void setMchId(String mchId) {
        this.mchId = mchId;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getReqUrl() {
        return reqUrl;
    }

    public void setReqUrl(String reqUrl) {
        this.reqUrl = reqUrl;
    }

    public String getPayType() {
        return payType;
    }

    public void setPayType(String payType) {
        this.payType = payType;
    }
}
